import request from "@/utils/request";

// 新的profile schema API
// 对string版本的操作
export function getProfileSchemaStr() {
  return request({
    url: "/profileSchemaStr",
    method: "get",
  });
}

export function editProfileSchemaStr(data) {
  return request({
    url: "/profileSchemaStr/edit",
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: data,
  });
}

// 对list版本的操作
export function getProfileSchema() {
  return request({
    url: "/profileSchema",
    method: "get",
  });
}

export function createProfileSchema(data) {
  return request({
    url: "/profileSchema/add",
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: data,
  });
}

export function deleteProfileSchema(key) {
  return request({
    url: `/profileSchema/${key}`,
    method: "delete",
  });
}

export function updateProfileSchema(data) {
  return request({
    url: "/profileSchema",
    method: "PUT",
    headers: {
      "Content-Type": "application/json",
    },
    data: data,
  });
}

export function searchProfileSchema(data) {
  return request({
    url: "/profileSchema",
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: data,
  });
}

// 对mongo数据库的profile表操作
export function getProfileById(id) {
  return request({
    url: `/profile/one`,
    method: 'GET'
  })
}

export function getProfile() {
  return request({
    url: "/profile",
    method: "get",
  });
}

export function modifyProfile(data) {
  return request({
    url: "/profile",
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: data,
  });
}

export function deleteUserProfile(user_id) {
  return request({
    url: `/profileSchema/deleteUserProfile`,
    method: "delete",
  });
}
